<?php

namespace App\Http\Controllers;

use App\Models\ChatGroup;
use App\Models\ChatGroupMessages;
use App\Services\WebSocketTokenService;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Auth;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    
    public function getChatGroup(Request $request)
    {
    	$auth_id = Auth::guard('web')->user()->chatUser->id;
    	$where = [];
    	$where[] = ['inviter_id', '=', $auth_id];
    	$where[] = ['invitee_id', '=', $auth_id, "or"];
    	$message = ChatGroupMessages::query()->where('chat_group_id', 1)->orderByDesc('id')->limit(10)->get();

    	dd($message[0]->only(['id', 'chat_group_id', 'chat_user_id', 'type', 'content', 'read_num', 'created_at']));
    }
}
